﻿using System;

namespace ConsoleApp_c2
{
    public delegate void ClockHandler(object sender, ClockEventArgs args);
    public class ClockEventArgs
    {
        public int Second { get; set; }
        public int Minute { get; set; }
        public int Hour { get; set; }
    } 
    public class Clock
    {
        public event ClockHandler Tick;
        public event ClockHandler Alarm;
        public int hour1, minute1, second1;
        public void Set_Alarm(int x,int y,int z) {
            Console.WriteLine("设置响铃时间为" + x + ":" + y + ":" + z);
            hour1 = x;
            minute1 = y;
            second1 = z;
        }
        public void Set_Clock(int x,int y,int z)
        {
            Console.WriteLine("当前时间为"+x+":"+y+":"+z);
            ClockEventArgs args = new ClockEventArgs()
            {
                Hour = x,
                Minute = y,
                Second = z
            };
            if (args.Hour==hour1&&args.Minute==minute1&&args.Second==second1) {
                Alarm(this, args); 
            }
            else Tick(this, args);
        }
    }
    public class Form
    {
        public Clock clock = new Clock();
        public Form()
        {
            clock.Tick += Tick_show;
            clock.Alarm += Alarm_show;
        }
        void Tick_show(object sender, ClockEventArgs args)
        {
            Console.WriteLine("嘀嗒");
        }
        void Alarm_show(object sender, ClockEventArgs args)
        {
            Console.WriteLine("响铃");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            Form form = new Form();
            form.clock.Set_Alarm(7,30,0);
            Console.WriteLine("设置当前时间为:" );
            int current_hour = Convert.ToInt32(Console.ReadLine());
            int current_minute = Convert.ToInt32(Console.ReadLine());
            int current_second = Convert.ToInt32(Console.ReadLine());
            form.clock.Set_Clock(current_hour,current_minute,current_second);
        }
    }
}
